package ae.pcfc.etks.online.web.controller.error;


import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import ae.pcfc.etks.online.common.exception.AccessDeniedException;
import ae.pcfc.etks.online.web.ViewPath;
import ae.pcfc.etks.online.web.controller.BaseController;

/**
 * 
 * 
 * @author Raif.Mahmoud
 */
@Controller
@RequestMapping(ViewPath.ERROR)
public class ErrorController extends BaseController{

	/**
	 * Custom handler for generic errors, i.e.: GET requests for
	 * /error/show.htm
	 * 
	 */
	@RequestMapping(value = ViewPath.ERROR_GENERIC, method = RequestMethod.GET)
	public void show(HttpServletRequest request) {	
		
	}
	/**
	 * Custom handler for generic errors, i.e.: GET requests for
	 * /error/system/validation/show.htm
	 * 
	 */
	@RequestMapping(value = ViewPath.ERROR_SYSTEM_VALIDATION, method = RequestMethod.GET)
	public void showSystemValidationError(HttpServletRequest request) {
		/*, @ModelAttribute(value=SimpleMappingExceptionResolver.DEFAULT_EXCEPTION_ATTRIBUTE) Exception exception
		if(exception instanceof SytemException){
			String messageKey = ViewUtils.getExceptionErrorMessageKey((SytemException)exception);
			if(messageKey != null){
				request.setAttribute("messageKey",messageKey);
				SytemException sytemException = (SytemException)exception;
				List<String> argsList = sytemException.getErrorMessageArgList();
				if(argsList != null && argsList.size() > 0 ){
					request.setAttribute("args",argsList.toArray(new String[argsList.size()]));
				}
			}
		}
			System.out.println(exception.getClass());*/	
		String errorCode = request.getParameter("error");
		if(request.getParameter("error") !=null && request.getParameter("error").equals("5"))
		throw new AccessDeniedException();
	}

}
